package com.burstly.lib.util;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

final class Crypto
{
  private static final String AES = "AES";
  private static final String ASCII = "ASCII";

  private static byte[] base64Decode(byte[] paramArrayOfByte)
  {
    return Base64.decode(paramArrayOfByte, 2);
  }

  private static String base64Encode(byte[] paramArrayOfByte)
  {
    return Base64.encodeToString(paramArrayOfByte, 2);
  }

  private static byte[] copyOf(byte[] paramArrayOfByte, int paramInt)
  {
    byte[] arrayOfByte = new byte[paramInt];
    System.arraycopy(paramArrayOfByte, 0, arrayOfByte, 0, Math.min(paramArrayOfByte.length, paramInt));
    return arrayOfByte;
  }

  static String decrypt(String paramString1, String paramString2)
    throws Exception
  {
    return new String(decrypt(paramString1.getBytes("ASCII"), base64Decode(paramString2.getBytes("ASCII"))));
  }

  private static byte[] decrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws Exception
  {
    SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramArrayOfByte1, "AES");
    Cipher localCipher = Cipher.getInstance("AES/CBC/ZeroBytePadding");
    localCipher.init(2, localSecretKeySpec, new IvParameterSpec(new byte[16]));
    return localCipher.doFinal(paramArrayOfByte2);
  }

  static String encrypt(String paramString1, String paramString2)
    throws Exception
  {
    return base64Encode(encrypt(paramString1.getBytes(), paramString2.getBytes("ASCII")));
  }

  private static byte[] encrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws Exception
  {
    byte[] arrayOfByte = copyOf(paramArrayOfByte2, 1 + paramArrayOfByte2.length);
    SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramArrayOfByte1, "AES");
    Cipher localCipher = Cipher.getInstance("AES/CBC/ZeroBytePadding");
    localCipher.init(1, localSecretKeySpec, new IvParameterSpec(new byte[16]));
    return localCipher.doFinal(arrayOfByte);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.util.Crypto
 * JD-Core Version:    0.6.2
 */